<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../css/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
</head>
<body>
<header class="aui-bar aui-bar-nav" id="aui-header"
        style="background: linear-gradient(90deg, #FA7C54 0%, #FD3F69 100%); font-size:16px">
    <a class="aui-btn aui-pull-left" tapmode onclick="closeWin() " style="color:#FFF">
        <span class="aui-iconfont aui-icon-left" style="color:#FFF"> </span>返回
    </a>
    <a class="aui-btn aui-pull-left" tapmode onclick="closeWd()" style="color:#FFF">
        关闭
    </a>
    <div id="title" class="aui-title" style="color:#FFF">直达影视</div>
    <a onclick="playVideo()" tapmode class="aui-navBar-item" style="color: #ffffff; ">
        <i class="icon icon-bofang1"></i>播放
    </a>


</header>

</body>
<script type="text/javascript" src="../script/api5.js"></script>
<script type="text/javascript">
    var dataurl = '';
    var dataurl2 = '';
    var qiyiurl = '';
    var dcode = 1;
    var onoff = true;
    var jx_url1 = localStorage.getItem('jx_url1');
    var jx_url2 = localStorage.getItem('jx_url2');

    apiready = function () {
        var api_url = localStorage.getItem('api_url');

        api.parseTapmode();
        var header = $api.byId('aui-header');
        $api.fixStatusBar(header);
        var headerPos = $api.offset(header);
        var body_h = $api.offset($api.dom('body')).h;


        var user_id = localStorage.getItem('user_id');
        if (user_id > 1) {

            api.ajax({
                url: api_url + '/login/login/imei.html',
                method: 'get',
                data: {
                    values: {
                        uid: user_id
                    }
                }
            }, function (ret, err) {
                if (ret) {
                    localStorage.setItem('jx_url1', ret.msg.url1);
                    localStorage.setItem('jx_url2', ret.msg.url2);
                    localStorage.setItem('jx_url3', ret.msg.url3);
                    localStorage.setItem('jx_url4', ret.msg.url4);
                    localStorage.setItem('jx_url5', ret.msg.url5);
                    localStorage.setItem('jx_url6', ret.msg.url6);

                    if (ret.msg.imei != api.deviceId) {
                        localStorage.setItem('user_id', '');
                        localStorage.setItem('user_name', '');
                        localStorage.setItem('user_time', '');
                        api.sendEvent({
                            name: 'newLoingdata',
                            extra: {}
                        });

                        api.closeWin({});

                        api.alert({
                            title: '您已在其他设备登陆！账号已强制下线',
                            msg: '请重新登陆',
                        });
                        return;


                    }
                } else {


                }
            });
        }


        api.addEventListener({
            name: 'keyback'
        }, function (ret, err) {
            api.hideProgress();
            api.setScreenOrientation({
                orientation: 'portrait_up'
            });
            var browser = api.require('webBrowser');
            browser.historyBack(
                function (ret, err) {
                    if (!ret.status) {
                        api.closeWin();
                    }
                }
            );
        });


        var browser = api.require('webBrowser');
        browser.openView({
            url: api.pageParam.url,
            rect: {
                x: 0,
                y: headerPos.h,
                w: 'auto',
                h: 'auto'
            }
        }, function (ret, err) {
            // api.alert({
            //     msg: JSON.stringify(ret)
            // });
            switch (ret.state) {
                case 0:

                    dataurl = ret.url;
                    dataurl2 = dataurl;

                    var txurlc = dataurl2.split(":");
                    var txurl = txurlc[1].slice(0, 12);
                    var ykurl = txurlc[1].slice(0, 13);
                    var ykdata = txurlc[1].slice(13);
                    var funurl = txurlc[1].slice(0, 11);
                    //alert(ykurl);

                    if (ykurl == '//m.youku.com') {

                        var txurlc = dataurl2.split(":");
                        var ykurl = txurlc[1].slice(0, 13);
                        var ykdata = txurlc[1].slice(13);
                        dataurl2 = 'http://www.youku.com' + ykdata;
                    } else {

                    }
                    if (ykurl == '//m.iqiyi.com') {

                        var txurlc = dataurl2.split(":");
                        var ykurl = txurlc[1].slice(0, 13);
                        var ykdata = txurlc[1].slice(13);
                        dataurl2 = 'https://www.iqiyi.com' + ykdata;

                    } else {

                    }
                    if (txurl == '//m.v.qq.com') {
                        var txdata = dataurl2;

                        var vid = getParam('vid');
                        var txdata2 = dataurl2.split("?");
                        var cid = txdata2[0].slice(-20, -5)


                        if (vid.length == 11) {
                            dataurl2 = 'https://v.qq.com/x/cover/' + cid + '/' + vid + '.html';

                        } else {
                            dataurl2 = 'https://v.qq.com/x/cover/' + cid + '.html';

                        }

                    } else {

                    }
                    if (ykurl == '//m.le.com/vp') {
                        var leurlc = dataurl2.split("_");
                        var leurl = leurlc[1];
                        dataurl2 = 'http://www.le.com/ptv/vplay/' + leurl;
                    } else {

                    }
                    var txdeurl = dataurl2.split(":");
                    var detxurl = txdeurl[1].slice(0, 29);
                    if (detxurl == '//v.qq.com/x/cover/.v.qq.com/') {
                        dataurl2 = 'https://v.qq.com/';
                    } else {

                    }

                    var bturl = dataurl2.split(":");
                    var feurl = bturl[1];


                    if (feurl.slice(0, 18) == '//www.iqiyi.com/v_' || feurl.slice(0, 19) == '//v.qq.com/x/cover/' || feurl.slice(0, 17) == '//m.tv.sohu.com/v' || feurl.slice(0, 23) == '//m.film.sohu.com/album' || feurl.slice(0, 14) == '//m.mgtv.com/b' || feurl.slice(0, 21) == '//www.youku.com/video' || feurl.slice(0, 22) == '//www.le.com/ptv/vplay' || feurl.slice(0, 30) == '//www.wasu.cn/wap/play/show/id' || feurl.slice(0, 30) == '//www.wasu.cn/wap/Play/show/id' || feurl.slice(0, 17) == '//m.pptv.com/show' || feurl.slice(0, 60) == '//m.miguvideo.com/wap/resource/migu/miguH5/detail/detail.jsp') {

                        if (!onoff) {
                            return;
                        }


                    } else {

                    }

                    //alert(dataurl2);
                    break;
                case 1:
                    break;
                case 2:
                    break;
                case 3:
                    var title = $api.byId('title');
                    title.innerHTML = ret.title;
                    break;
                case 4:
                    break;
                default:
                    var title = $api.byId('title');
                    title.innerHTML = ret.title;
                    break;
            }
            ;

        });


    }


    function getCaption(obj) {
        var index = obj.lastIndexOf("\=");
        obj = obj.substring(index + 1, obj.length);
        return obj;
    }

    function closeWin() {
        api.setScreenOrientation({
            orientation: 'portrait_up'
        });
        var browser = api.require('webBrowser');
        browser.historyBack(
            function (ret, err) {
                if (!ret.status) {
                    var dialogBox = api.require('dialogBox');
                    dialogBox.raffle({
                        texts: {
                            subText: '播放是否异常？',
                            leftTitle: '是[反馈]',
                            rightTitle: '否[退出]'
                        },
                        styles: {
                            bg: '#fff',
                            w: 300,
                            icon: {
                                marginT: 0,
                                w: 300,
                                h: 150,
                                iconPath: 'widget://image/exitback.jpg'
                            },
                            main: {
                                marginT: 0,
                                color: '#636363',
                                size: 13
                            },
                            sub: {
                                marginT: 0,
                                color: '#999999',
                                size: 14
                            },
                            left: {
                                marginB: 7,
                                marginL: 18,
                                w: 130,
                                h: 35,
                                corner: 2,
                                bg: '#fff',
                                color: '#007FFF',
                                size: 15
                            },
                            right: {
                                marginB: 7,
                                marginL: 18,
                                w: 130,
                                h: 35,
                                corner: 2,
                                bg: '#fff',
                                color: '#007FFF',
                                size: 15
                            }
                        }
                    }, function (ret, err) {
                        if (ret.eventType == 'left') {
                            var dialogBox = api.require('dialogBox');
                            dialogBox.close({
                                dialogName: 'raffle'
                            });
                            api.toast({
                                msg: '反馈提交成功！我们会尽快修复',
                                duration: 3000,
                                location: 'middle'
                            });

                        } else if (ret.eventType == 'right') {
                            var dialogBox = api.require('dialogBox');
                            dialogBox.close({
                                dialogName: 'raffle'
                            });
                            api.clearCache(function () {

                            });

                            api.closeWin();
                        }
                    });
                    //api.closeWin();

                }
            }
        );
    }

    function jieXi() {
        api.actionSheet({
            title: '专线VIP线路',
            cancelTitle: '取消',
            buttons: ['VIP线路1', 'VIP线路2', 'VIP线路3', 'VIP线路4', 'VIP线路5']
        }, function (ret, err) {
            var index = ret.buttonIndex;
            //alert( JSON.stringify( ret ) );
            if (ret.buttonIndex == 1) {
                vipHuanxian(localStorage.getItem('jx_url2'));
            }
            if (ret.buttonIndex == 2) {
                vipHuanxian(localStorage.getItem('jx_url3'));
            }
            if (ret.buttonIndex == 3) {
                vipHuanxian(localStorage.getItem('jx_url4'));
            }
            if (ret.buttonIndex == 4) {
                vipHuanxian(localStorage.getItem('jx_url5'));
            }
            if (ret.buttonIndex == 5) {
                vipHuanxian(localStorage.getItem('jx_url6'));
            }
        });
    }


    function huanxian() {

        var user_id = localStorage.getItem('user_id');
        if (user_id < 1) {
            api.alert({
                title: '温馨提示',
                msg: '请先登陆后使用',
            });
            api.openWin({
                name: 'login',
                url: './login.html',
                delay: 300
            });
            return;

        }
        api.showProgress({
            title: '获取VIP信息',
            modal: false
        });
        var browser = api.require('webBrowser');
        browser.loadScript({
            script: 'location.reload();'
        });
        setTimeout("playVideo();", 1500);

    }

    function playVideo() {
        api.hideProgress();


        var systemType = api.systemType;
        if (systemType == 'ios') {
            api.openWin({
                name: 'play_win',
                url: './play_win.html',
                delay: 300,
                pageParam: {url: jx_url2 + dataurl2, srcUrl: dataurl2},
                bgColor: '#000000'
            });
        } else if (systemType == 'android') {
            api.openWin({
                name: 'play_win',
                url: './play_win.html',
                delay: 300,
                pageParam: {url: jx_url2 + dataurl2, srcUrl: dataurl2},
                bgColor: '#000000'
            });
        } else {
            var browser = api.require('webBrowser');
            browser.open({
                url: jx_url2 + dataurl2,
                titleBar: {
                    visible: true
                }
            });

        }


    }


    function getParam(name) {

        return dataurl2.match(new RegExp('[?&]' + name + '=([^?&]+)', 'i')) ? decodeURIComponent(RegExp.$1) : '';

    }

    function closeWin() {
        var browser = api.require('webBrowser');
        browser.historyBack(
            function (ret, err) {
                if (!ret.status) {
                    api.closeWin();
                }
            }
        );
    }

    function closeWd() {
        api.closeWin();
    }


    function vipHuanxian(jiekou) {
        var user_id = localStorage.getItem('user_id');
        if (user_id < 1) {
            api.alert({
                title: '温馨提示',
                msg: '请先登陆后使用',
            });
            api.openWin({
                name: 'login',
                url: './login.html',
                delay: 300
            });
            return;

        }

        var systemType = api.systemType;
        if (systemType == 'android') {
            api.openWin({
                name: 'play_win',
                url: './play_win.html',
                delay: 300,
                pageParam: {url: jiekou + dataurl2},
                bgColor: '#000000'
            });
        } else {
            var browser = api.require('webBrowser');
            browser.open({
                url: jiekou + dataurl2,
                titleBar: {
                    visible: true
                }
            });

        }


    }


</script>

</html>
